package ru.magicreader;

import java.io.IOException;

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;

public class PersistenceFacade {
	private static PersistenceFacade instance;
	
	private PersistenceManagerFactory pmf;
	
	private PersistenceFacade() throws IOException {
		pmf = JDOHelper.getPersistenceManagerFactory("transactions-optional");
	}
	
	public static PersistenceFacade getInstance() {
		if(instance != null) return instance;
		try {
			return new PersistenceFacade();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	
	public PersistenceManager getPersistenceManager() {
		return pmf.getPersistenceManager();
	}
}
